package com.hankol.feature_wine_meal.adapter

import android.annotation.SuppressLint
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.feature_wine_meal.R
import com.hankol.feature_wine_meal.bean.RecommendFoodBean
import java.util.ArrayList

/**
 * @author: 关忆北、
 * @date: 2022/6/17
 * @Des：
 */
class EliteTabAdapter : BaseQuickAdapter<RecommendFoodBean, BaseViewHolder>(R.layout.item_elite_tab) {
    override fun convert(helper: BaseViewHolder, item: RecommendFoodBean) {
        val resources = mContext.resources
        helper.setText(R.id.tv_eliteFood_tab, item.name)
                .setTextColor(R.id.tv_eliteFood_tab, resources.getColor(if (item.isSelected) R.color.white else R.color.color_F54D53))
                .setBackgroundRes(R.id.tv_eliteFood_tab, if (item.isSelected) R.drawable.shape_f54d53_solid_20dp else R.drawable.shape_f54d53_alpha90_solid_20dp)
    }

    @SuppressLint("NotifyDataSetChanged")
    fun upSelected(selectedPos: Int) {
        for (index in 0 until data.size) {
            data[index].isSelected = selectedPos == index
        }
        notifyDataSetChanged()
    }
}